import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

// 引入路由组件
// 初始首页
const Home = resolve => require(['../views/home'], resolve)
// 头部组件父路由
const FileHome = resolve => require(['../views/apiFileHome'], resolve)
// 头部组件子路由
const DevelopmentGuide = resolve => require(['../views/developmentGuide'], resolve)
const APIDocument = resolve => require(['../views/apiDocument'], resolve)
const Message = resolve => require(['../views/message'], resolve)
const ExtensionPoint = resolve => require(['../views/extensionPoint'], resolve)
const FrontExtension = resolve => require(['../views/frontExtension'], resolve)
const Solution = resolve => require(['../views/solution'], resolve)
const CommonProblem = resolve => require(['../views/commonProblem'], resolve)
const OperationNorm = resolve => require(['../views/OperationNorm'], resolve)
const Announcement = resolve => require(['../views/announcement'], resolve)
const Login = resolve => require(['../views/login'], resolve)
const Registered = resolve => require(['../views/registered'], resolve)
const DocumentCenter = resolve => require(['../views/documentCenter'], resolve)
// ***************************************************************************

const routes = [
  // 首页
  {
    path: '/',
    name: 'home',
    component: Home
  },
  //   登录
  {
    path: '/login',
    component: Login
  },
  //   注册
  {
    path: '/Registered',
    component: Registered
  },
  //   文档中心首页
  {
    path: '/apiFileHome',
    component: FileHome,
    // 文档中心子级路由
    children: [{
      path: '/developmentguide',
      component: DevelopmentGuide,
      children: [
        {
          path:'/',
          redirect:'baseDocument'
        },
        {
          path: 'baseDocument',
          component: () => import('@/views/developmentGuide/baseDocument/index.vue'),
          children: [
            {
              path:'/',
              redirect:'s1'
            },
            {
              path: 's1',
              component: () => import('@/views/developmentGuide/baseDocument/s1.vue')
            },
            {
              path: 's2',
              component: () => import('@/views/developmentGuide/baseDocument/s2.vue')
            },
            {
              path: 's3',
              component: () => import('@/views/developmentGuide/baseDocument/s3.vue')
            },
            {
              path: 's4',
              component: () => import('@/views/developmentGuide/baseDocument/s4.vue')
            },
            {
              path: '#',
              component: () => import('@/views/developmentGuide/baseDocument/s5.vue')
            },
          ],
        },
        {
          path: 'research',
          component: () => import('@/views/developmentGuide/research/index.vue'),
          children: [
            {
              path:'/',
              redirect:'s1'
            },
            {
              path: 's1',
              component: () => import('@/views/developmentGuide/research/s1.vue')
            },
            {
              path: 's2',
              component: () => import('@/views/developmentGuide/research/s2.vue')
            },
            {
              path: 's3',
              component: () => import('@/views/developmentGuide/research/s3.vue')
            },
            {
              path: 's4',
              component: () => import('@/views/developmentGuide/research/s4.vue')
            },
          ],
        },
        {
          path: 'appServe',
          component: () => import('@/views/developmentGuide/appServe/index.vue')
        },
        {
          path: 'appShop',
          component: () => import('@/views/developmentGuide/appShop/index.vue')
        },
        {
          path: 'designPlatform',
          component: () => import('@/views/developmentGuide/designPlatform/index.vue')
        },

        {
          path: 'IOT',
          component: () => import('@/views/developmentGuide/IOT/index.vue')
        },
        {
          path: 'commonlyTools',
          component: () => import('@/views/developmentGuide/commonlyTools/index.vue')
        },
      ]
    },
    {
      path: '/apidocument',
      component: APIDocument
    },
    {
      path: '/message',
      component: Message
    },
    {
      path: '/extensionPoint',
      component: ExtensionPoint
    },
    {
      path: '/frontextension',
      component: FrontExtension
    },
    {
      path: '/solution',
      component: Solution
    },
    {
      path: '/commonproblem',
      component: CommonProblem
    },
    {
      path: '/operationnorm',
      component: OperationNorm,
      
      children: [
        {
          path:'/',
          redirect:'docOne'
        },
        {
          path: 'docOne',
          component: () => import('@/views/OperationNorm/docOne.vue')
        },
        {
          path: 'docTwo',
          component: () => import('@/views/OperationNorm/docTwo.vue')
        },
        {
          path: 'docThree',
          component: () => import('@/views/OperationNorm/docThree.vue')
        },
        {
          path: 'docFour',
          component: () => import('@/views/OperationNorm/docFour.vue')
        },
        {
          path: 'docFive',
          component: () => import('@/views/OperationNorm/docFive.vue')
        },
      ]
    },
    {
      path: '/announcement',
      component: Announcement,
      children:[
        {
          path: '/',
          redirect:'docone'
        },
        {
          path: 'docone',
          component: () => import('@/views/announcement/docone.vue')
        },
        {
          path: 'doctwo',
          component: () => import('@/views/announcement/doctwo.vue')
        },
        {
          path: 'docthree',
          component: () => import('@/views/announcement/docthree.vue')
        },
        {
          path: 'docfour',
          component: () => import('@/views/announcement/docfour.vue')
        },
        {
          path: 'docfive',
          component: () => import('@/views/announcement/docfive.vue')
        },
        {
          path: 'docsix',
          component: () => import('@/views/announcement/docsix.vue')
        },
      ]
    }
    ]
  },
  // 文档中心
  {
    path: '/documentCenter',
    component: DocumentCenter
  }

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
